package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaNetMapper;
import com.ruoyi.work.domain.WorkMediaNet;
import com.ruoyi.work.service.IWorkMediaNetService;
import com.ruoyi.common.core.text.Convert;

/**
 * 网络媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaNetServiceImpl implements IWorkMediaNetService
{
    @Autowired
    private WorkMediaNetMapper workMediaNetMapper;
    @Autowired
    private WorkClientMapper workClientMapper;

    /**
     * 查询网络媒体资料
     * 
     * @param mediaId 网络媒体资料主键
     * @return 网络媒体资料
     */
    @Override
    public WorkMediaNet selectWorkMediaNetByMediaId(Long mediaId)
    {
        return workMediaNetMapper.selectWorkMediaNetByMediaId(mediaId);
    }

    /**
     * 查询网络媒体资料列表
     * 
     * @param workMediaNet 网络媒体资料
     * @return 网络媒体资料
     */
    @Override
    public List<WorkMediaNet> selectWorkMediaNetList(WorkMediaNet workMediaNet)
    {
        return workMediaNetMapper.selectWorkMediaNetList(workMediaNet);
    }

    /**
     * 新增网络媒体资料
     * 
     * @param workMediaNet 网络媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaNet(WorkMediaNet workMediaNet)
    {
        workMediaNet.setCreateTime(DateUtils.getNowDate());
        workMediaNet.setContacts(workClientMapper.selectWorkClientByClientId(workMediaNet.getContactId()).getClientName());
        return workMediaNetMapper.insertWorkMediaNet(workMediaNet);
    }

    /**
     * 修改网络媒体资料
     * 
     * @param workMediaNet 网络媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaNet(WorkMediaNet workMediaNet)
    {
        workMediaNet.setUpdateTime(DateUtils.getNowDate());
        return workMediaNetMapper.updateWorkMediaNet(workMediaNet);
    }

    /**
     * 批量删除网络媒体资料
     * 
     * @param mediaIds 需要删除的网络媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaNetByMediaIds(String mediaIds)
    {
        return workMediaNetMapper.deleteWorkMediaNetByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除网络媒体资料信息
     * 
     * @param mediaId 网络媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaNetByMediaId(Long mediaId)
    {
        return workMediaNetMapper.deleteWorkMediaNetByMediaId(mediaId);
    }

}
